#ifndef   _RENDER_CONSOLE_H__
#define   _RENDER_CONSOLE_H__

#pragma comment(lib, "d3d9.lib")

#include <d3d9.h>

typedef unsigned char uint8;

class RenderConsole
{
public:

	static RenderConsole* Instance();

	 //call this func to init d3d and create a console window..
    bool InitializeConsole(int width, int height, HWND mainWindowHandle, bool windowed);

	bool LockBackBuffer();         //call this func before render.. 
	bool UnlockBackBuffer();       //call this func after render..
	void SwapBackBuffer();

	/*basic draw func..*/
	void SetClearColor(int clearColor);      //set clear screen color..
	void ClearBackBuffer();                    //clear screen..

	inline void SetPixelARGB(int x, int y, DWORD color);  //set a pixel color..

	void BresenhamLine(int x0, int y0, int x1, int y1 , DWORD color);

private:
	RenderConsole();
	~RenderConsole();

private:
	int        mWidth;
	int        mHeight;


	IDirect3D9*                   mD3d9;                  //D3D ptr..
	IDirect3DDevice9*             mDevice9;               //D3D device...
    IDirect3DSurface9*            mOffScreenSurface9;     //off screen surface.. Do not use this directly, use func.
	IDirect3DSurface9*            mBackBufferSurface9;    //back buffer surface..  Do not use this directly, use func.

	uint8*                        mBackBuffer;            //off screen buffer..

	unsigned int                  mClearColor;            //clear screen color..

	static RenderConsole*         mConsole;
};


#endif